package com.wicket.okrframework.web.contorller;

import com.github.pagehelper.Page;
import com.wicket.okrframework.biz.service.OrgPositionService;
import com.wicket.okrframework.biz.service.dto.req.*;
import com.wicket.okrframework.biz.service.dto.res.*;
import com.wicket.okrframework.common.ro.OkrResult;
import com.wicket.okrframework.common.util.CommonFunctionHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@RestController
@RequestMapping("/base/orgPosition/")
public class OrgPositionController {

    @Autowired
    OrgPositionService orgPositionService;

    /**
   * D1-3查询部门职务明细列表
   */
    @PostMapping("queryDeptPositionInfoList")
    public OkrResult<QueryDeptPositionInfoListRespDto> queryDeptPositionInfoList(@RequestBody @Validated QueryDeptPositionInfoListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryDeptPositionInfoListRespDto retData = orgPositionService.queryDeptPositionInfoList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

    /**
   * D1-3查询组织/部门岗位明细列表
   */
    @PostMapping("queryDeptStationInfoList")
    public OkrResult<QueryDeptStationInfoListRespDto> queryDeptStationInfoList(@RequestBody @Validated QueryDeptStationInfoListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryDeptStationInfoListRespDto retData = orgPositionService.queryDeptStationInfoList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

    /**
   * D1-3查询部门下岗位列表
   */
    @PostMapping("queryDeptStationList")
    public OkrResult<QueryDeptStationListRespDto> queryDeptStationList(@RequestBody @Validated QueryDeptStationListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryDeptStationListRespDto retData = orgPositionService.queryDeptStationList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

    /**
   * D1-3查询组织部门职务列表（边界）
   */
    @PostMapping("queryOrgDeptPositionListBorder")
    public OkrResult<QueryOrgDeptPositionListBorderRespDto> queryOrgDeptPositionListBorder(@RequestBody @Validated QueryOrgDeptPositionListBorderReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryOrgDeptPositionListBorderRespDto retData = orgPositionService.queryOrgDeptPositionListBorder(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

/**
   * D1执行批次发布部门职务处理(公共)
   */
    @PostMapping("implementBatchFileDeptPositionHandleCom")
    public OkrResult<ImplementBatchFileDeptPositionHandleComRespDto> implementBatchFileDeptPositionHandleCom(@RequestBody @Validated ImplementBatchFileDeptPositionHandleComReqDto reqDTO){
    return OkrResult.success(orgPositionService.implementBatchFileDeptPositionHandleCom(reqDTO));
    }
/**
   * D1-3查询职务归属组织列表
   */
    @PostMapping("queryPositionOrgList")
    public OkrResult<QueryPositionOrgListRespDto> queryPositionOrgList(@RequestBody @Validated QueryPositionOrgListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryPositionOrgListRespDto retData = orgPositionService.queryPositionOrgList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }
}
